package com.wwu.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wwu.common.constant.CommConst;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 系统登陆日志实体
 * @author 一蓑烟雨
 * @date 2023/5/31 9:35
 */
@Data
@Accessors(chain = true)
@TableName("sys_login_log")
@ApiModel(value="SysLoginLog:系统登陆日志实体", description="系统登陆日志实体")
public class LoginLog implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "日志id")
    @TableId(value = "record_id", type = IdType.ASSIGN_ID)
    private String recordId;

    @ApiModelProperty(value = "会话id")
    @TableField(value = "session_id")
    private String sessionId;

    @ApiModelProperty(value = "登陆名")
    @TableField("user_name")
    private String userName;

    @ApiModelProperty(value = "用户昵称")
    @TableField("nick_name")
    private String nickName;

    @ApiModelProperty(value = "登陆IP地址")
    @TableField("login_ip")
    private String loginIp;

    @ApiModelProperty(value = "登陆主机名")
    @TableField("login_remote_host")
    private String loginRemoteHost;

    @ApiModelProperty(value = "登陆位置")
    @TableField("login_location")
    private String loginLocation;

    @ApiModelProperty(value = "登陆状态(0:成功；1:失败)）")
    @TableField("login_status")
    private Integer loginStatus;

    @ApiModelProperty(value = "日志描述")
    @TableField("login_desc")
    private String loginDesc;

    @ApiModelProperty(value = "登陆浏览器")
    @TableField("browser")
    private String browser;

    @ApiModelProperty(value = "登陆操作系统")
    @TableField("os")
    private String os;

    @ApiModelProperty(value = "登陆时间")
    /** 格式化后台和前端显示样式 */
    @DateTimeFormat(pattern = CommConst.DATE_TIME)
    @JsonFormat(pattern = CommConst.DATE_TIME,timezone = CommConst.TIME_ZONE)
    @TableField(value = "login_time")
    private LocalDateTime loginTime;

    @ApiModelProperty(value = "退出时间")
    /** 格式化后台和前端显示样式 */
    @DateTimeFormat(pattern = CommConst.DATE_TIME)
    @JsonFormat(pattern = CommConst.DATE_TIME,timezone = CommConst.TIME_ZONE)
    @TableField(value = "logout_time")
    private LocalDateTime logoutTime;

    @ApiModelProperty(value = "登陆时长(单位:小时)")
    @TableField(value = "login_duration")
    private float loginDuration;
}
